add show page for the new agent

Andrew Cantino 10 anni fa
parent
commit
ea8963a8cf

+ 2 - 3
app/models/agents/data_output_agent.rb

@@ -8,7 +8,7 @@ module Agents
8 8
 
9 9
         This Agent will output data at:
10 10
 
11
-        `https://#{ENV['DOMAIN']}/users/#{user.id}/web_requests/#{id || '<id>'}/:secret.xml`
11
+        `https://#{ENV['DOMAIN']}/users/#{user.id}/webhooks/#{id || '<id>'}/:secret.xml`
12 12
 
13 13
         where `:secret` is one of the allowed secrets specified in your options and the extension can be `xml` or `json`.
14 14
 
@@ -89,10 +89,9 @@ module Agents
89 89
             'title' => feed_title,
90 90
             'description' => feed_description,
91 91
             'pubDate' => Time.now,
92
+            'items' => items
92 93
           }
93 94
 
94
-          content['items'] = items
95
-
96 95
           return [content, 200]
97 96
         else
98 97
           content = Utils.unindent(<<-XML)

+ 12 - 0
app/views/agents/agent_views/data_output_agent/_show.html.erb

@@ -0,0 +1,12 @@
1
+<p>
2
+  Data for this Agent is available at these URLs:
3
+</p>
4
+
5
+
6
+<ul>
7
+  <% @agent.options['secrets'].each do |secret| %>
8
+    <% url = lambda { |format| webhooks_url(:agent_id => @agent.id, :user_id => current_user.id, :secret => secret, :format => format) } %>
9
+    <li><%= link_to url.call(:json), url.call(:json), :target => :blank %></li>
10
+    <li><%= link_to url.call(:xml), url.call(:xml), :target => :blank %></li>
11
+  <% end %>
12
+</ul>

+ 1 - 1
config/routes.rb

@@ -31,7 +31,7 @@ Huginn::Application.routes.draw do
31 31
   match "/worker_status" => "worker_status#show"
32 32
 
33 33
   post "/users/:user_id/update_location/:secret" => "user_location_updates#create"
34
-  match "/users/:user_id/webhooks/:agent_id/:secret" => "webhooks#handle_request"
34
+  match "/users/:user_id/webhooks/:agent_id/:secret" => "webhooks#handle_request", :as => :webhooks
35 35
 
36 36
 #  match "/delayed_job" => DelayedJobWeb, :anchor => false
37 37
   devise_for :users, :sign_out_via => [ :post, :delete ]